net/vnstat: port the init-script to procd
authorMartin Blumenstingl <[email protected]>
Sun, 23 Jul 2017 09:59:01 +0000 (11:59 +0200)
committerMartin Blumenstingl <[email protected]>
Thu, 31 May 2018 11:03:38 +0000 (13:03 +0200)
This ports the init-script from the legacy functions to procd. There
should be no functional changes with this patch.

Signed-off-by: Martin Blumenstingl <[email protected]>
net/vnstat/files/vnstat.init

index 7921cbcde2291926d0a6cbdf84f099a15a029dfd..cc9cdc7cc17ab4b6a337834bacd827b388050f75 100644 (file)
@@ -3,25 +3,21 @@
 
 START=99
 
+USE_PROCD=1
+
 vnstat_option() {
        sed -ne "s/^[[:space:]]*$1[[:space:]]*['\"]\([^'\"]*\)['\"].*/\1/p" \
                /etc/vnstat.conf
 }
 
-start() {
+start_service() {
        local lib="$(vnstat_option DatabaseDir)"
-       local pid="$(vnstat_option PidFile)"
 
        [ -n "$lib" ] || {
                echo "Error: No DatabaseDir set in vnstat.conf" >&2
                exit 1
        }
 
-       [ -n "$pid" ] || {
-               echo "Error: No PidFile set in vnstat.conf" >&2
-               exit 1
-       }
-
        mkdir -p "$lib"
 
        init_ifaces() {
@@ -72,18 +68,18 @@ start() {
        config_load vnstat
        config_foreach init_ifaces vnstat
 
-       SERVICE_PID_FILE="${pid}"
-       service_start /usr/sbin/vnstatd -d
+       procd_open_instance
+       procd_set_param stdout 1
+       procd_set_param stderr 1
+       procd_set_param command /usr/sbin/vnstatd --nodaemon
+       procd_set_param file /etc/vnstat.conf
+       procd_close_instance
 }
 
-stop() {
-       local pid="$(vnstat_option PidFile)"
-
-       [ -n "$pid" ] || {
-               echo "Error: No PidFile set in vnstat.conf" >&2
-               exit 1
-       }
+reload_service() {
+       procd_send_signal vnstat
+}
 
-       SERVICE_PID_FILE="${pid}"
-       service_stop /usr/sbin/vnstatd
+service_triggers() {
+       procd_add_reload_trigger vnstat
 }